﻿using UnityEngine;
using System.Collections;
using ProtoBuf.Message;

namespace Room
{
    public class PlayerAIStateAttack : PlayerAIStateBase
    {
        //float timeLast = 60f;
        //float currentTime = 0f;
        GameObject att;
        protected override void OnEnter()
        {
            if(att!=null)
            {
                GameObjectPoolManager.Instance.Unspawn(att);
            }

            controller.owner.PlayAnim(AniName.IDLE_FIGHT);
            //currentTime = 0f;
            //timeLast = Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.FieldPVPKeep;

            att = GameObjectPoolManager.Instance.Spawn(RoomField.particleAttAb, CommonMethod.GetAssetNameFromAssetBundleName(RoomField.particleAttAb));
            att.transform.SetParent(controller.owner.transform);
            att.transform.localScale = Vector3.one;
            att.transform.localPosition = Vector3.zero + new Vector3(0, 2, 0); ;
            //att.transform.SetParent(controller.owner.transform.parent);
            att.SetActive(true);

            //如果是自己
            //if (long.Parse(controller.owner.name) == StaticData.playerData.playerId)
            //{
            //    if (RoomManager.curSceneType == SceneType.FIELD)
            //    {
                    
            //        CSSidePveFightEnd end = new CSSidePveFightEnd();
            //        end.fightId = "";
            //        NetAPI.SendSocket(OpDefine.CSSidePveFightEnd, end);
            //    }
            //}
            
        }
        
        protected override void OnLeave()
        {
            controller.owner.PlayAnim(AniName.STAND);
            GameObjectPoolManager.Instance.Unspawn(att);
        }
    }
}